home *** CD-ROM | disk | FTP | other *** search
- {$G+,X+}
-
- {Conditional defines that may affect this unit}
- {$I AWDEFINE.INC}
-
- {*********************************************************}
- {* BATCHUL.PAS 1.01 *}
- {* Copyright (c) TurboPower Software 1995 *}
- {* All rights reserved. *}
- {*********************************************************}
-
- unit Batchul;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, FileCtrl, Buttons, AdMisc, TComIni;
-
- type
- TBatchUploadForm = class(TForm)
- FileList: TFileListBox;
- DirList: TDirectoryListBox;
- GroupBox1: TGroupBox;
- Label1: TLabel;
- Label2: TLabel;
- DirLabel: TLabel;
- MaskEdit: TEdit;
- DriveBox: TDriveComboBox;
- OutgoingList: TListBox;
- Label4: TLabel;
- OkBtn: TBitBtn;
- CancelBtn: TBitBtn;
- HelpBtn: TBitBtn;
- AddBtn: TBitBtn;
- RemoveBtn: TBitBtn;
- procedure FileListDblClick(Sender: TObject);
- procedure OkBtnClick(Sender: TObject);
- procedure AddBtnClick(Sender: TObject);
- procedure RemoveBtnClick(Sender: TObject);
- procedure OutgoingListDblClick(Sender: TObject);
-
- private
- OutList : TStrings;
-
- function FileInOutgoing(const FName : String) : Boolean;
- {-Return TRUE if FName is in the outgoing file list}
-
- public
- constructor Create(AOwner : TComponent; AFileList : TStrings);
- end;
-
- implementation
-
- {$R *.DFM}
-
- function ContainsWildCards(const S : String) : Boolean;
- var
- I : Word;
-
- begin
- Result := True;
- for I := 1 to Length(S) do
- if (S[I] = '*') or (S[I] = '?') then
- Exit;
- Result := False;
- end;
-
- constructor TBatchUploadForm.Create(AOwner : TComponent; AFileList : TStrings);
- var
- Path : String;
-
- begin
- inherited Create(AOwner);
-
- OutList := AFileList;
-
- if IsDirectory(UploadDir) then
- Path := FullPathName(AddBackslash(UploadDir) + '*.*')
- else
- Path := '';
-
- MaskEdit.Text := '';
- DriveBox.Drive := Path[1];
- DirList.Directory := JustPathName(Path);
- end;
-
- function TBatchUploadForm.FileInOutgoing(const FName : String) : Boolean;
- {-Return TRUE if FName is in the outgoing file list}
- begin
- Result := (OutgoingList.Items.IndexOf(FName) <> -1);
- end;
-
- procedure TBatchUploadForm.FileListDblClick(Sender: TObject);
- var
- Path : String;
-
- begin
- Path := LowerCase(FileList.FileName);
- if (Path = '') then
- Exit;
-
- if not FileInOutgoing(Path) then begin
- OutgoingList.Items.Add(Path);
- OkBtn.Enabled := True;
- end;
- end;
-
- procedure TBatchUploadForm.OkBtnClick(Sender: TObject);
- var
- I : Word;
-
- begin
- if (OutgoingList.Items.Count <> 0) then begin
- for I := 0 to Pred(OutgoingList.Items.Count) do
- OutList.Add(OutgoingList.Items[I]);
- end else
- ModalResult := mrNone;
- end;
-
- procedure TBatchUploadForm.AddBtnClick(Sender: TObject);
- var
- I : Word;
- N : String;
- TempDir : String;
-
- begin
- {if there are any files selected, add those to the outgoing list}
- if not ContainsWildCards(MaskEdit.Text) and (FileList.SelCount <> 0) then begin
- Cursor := crHourGlass;
- for I := 0 to Pred(FileList.Items.Count) do
- if FileList.Selected[I] then
- OutgoingList.Items.Add(LowerCase(AddBackslash(FileList.Directory) + FileList.Items[I]));
- OkBtn.Enabled := True;
- Cursor := crDefault;
- end else begin
- {if nothing's entered, exit the form}
- N := TrimTrail(MaskEdit.Text);
- if (N = '') then begin
- ModalResult := mrOK;
- OkBtnClick(Sender);
- Exit;
- end;
-
- {get the fully qualified name of the file}
- N := LowerCase(ExpandFileName(N));
-
- {extract the directory portion of the filename}
- TempDir := JustPathname(N);
-
- {validate the directory}
- if not IsDirectory(TempDir) then begin
- MessageBeep(0);
- MaskEdit.SetFocus;
- Exit;
- end;
-
- {if the name contains no wildcards, add the file to the outgoing list}
- if not ContainsWildCards(N) then begin
- {make sure the file exists}
- if not FileExists(N) then begin
- MessageBeep(0);
- MaskEdit.SetFocus;
-
- {make sure the file isn't already in the list}
- end else if not FileInOutgoing(N) then begin
- OutgoingList.Items.Add(N);
- MaskEdit.Text := '';
- OkBtn.Enabled := True;
- end;
-
- {the name contains wildcards...reset the directory and mask and}
- {reload the listboxes with the new information }
- end else begin
- FileList.Mask := N;
- DirList.Directory := TempDir;
- MaskEdit.Text := '';
- end;
- end;
- end;
-
- procedure TBatchUploadForm.RemoveBtnClick(Sender: TObject);
- var
- I : Word;
-
- begin
- if (OutgoingList.SelCount = 0) then
- Exit;
-
- Cursor := crHourGlass;
- for I := Pred(OutgoingList.Items.Count) downto 0 do
- if OutgoingList.Selected[I] then
- OutgoingList.Items.Delete(I);
- OkBtn.Enabled := (OutgoingList.Items.Count <> 0);
- Cursor := crDefault;
- end;
-
- procedure TBatchUploadForm.OutgoingListDblClick(Sender: TObject);
- begin
- if (OutgoingList.ItemIndex <> -1) then begin
- OutgoingList.Items.Delete(OutgoingList.ItemIndex);
- OkBtn.Enabled := (OutgoingList.Items.Count <> 0);
- end;
- end;
-
- end.
-
-